package nav;

import java.util.List;

public class RouteImpl implements Route{

	private List<Coordinate> tour;
	private Coordinate[] pois;
	private double tourLength;
	private Coordinate[] orderedPOICoordinates;
	private List<Crossing> crossings;
	private String routeFileName;
	
	public RouteImpl(Coordinate[] pois, Coordinate[] orderedPOICoordinates, List<Coordinate> tour, double tourLength, List<Crossing> crossingsOrdered) {
		this.tour = tour;
		this.tourLength = tourLength;
		this.pois = pois;
		this.orderedPOICoordinates = orderedPOICoordinates;
		this.crossings = crossingsOrdered;
	}
	
	@Override
	public List<Crossing> getCrossings(){
		return crossings;
	}
	
	@Override
	public List<Coordinate> getTour(){
		return tour;
	}
	
	@Override
	public double getLength(){
		return tourLength;
	}
	
	@Override
	public Coordinate[] getPOIS(){
		return pois;
	}

	@Override
	public Coordinate[] getOrderedPOICoordinates(){
		return orderedPOICoordinates;
	}

	@Override
	public void setFileName(String routeFileName) {
		String fileName = getFileNameWithoutExtension(routeFileName);
		this.routeFileName = fileName + "_route.txt";
	}


	private String getFileNameWithoutExtension(String fullFileName) {
		String extensionSeperator = ".";
//		String pathSeperator = "/";
//		if(!fullFileName.contains(pathSeperator)){
//			pathSeperator = "\\";
//		}
		int dot = fullFileName.lastIndexOf(extensionSeperator);
//		int sep = fullFileName.lastIndexOf(pathSeperator);
		return fullFileName.substring(0, dot);
	}
	
	@Override
	public String getFileName() {
		return this.routeFileName;
	}
}
